package com.myzhouye.starter.ticket.config;/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

import com.myzhouye.starter.ticket.properties.TicketProperties;
import com.myzhouye.starter.ticket.service.IticketUtilService;
import com.myzhouye.starter.ticket.service.impl.DefaultTicketUtilService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @program: ticket-spring-boot-starter
 * @description: 自动配置
 * @author: 那条蠢鱼
 * @create: 2024-11-14 15:31
 **/
@Configuration
@EnableConfigurationProperties({TicketProperties.class})
public class TicketAutoConfigure {
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private TicketProperties ticketProperties;


    @Bean
    @ConditionalOnMissingBean
    public IticketUtilService ticketUnitService() {
        return new DefaultTicketUtilService(redisTemplate,ticketProperties);
    }
}
